
$(function(){

  // http://193.112.55.79:9090/api/getbrandtitle
  $.ajax({
    type: "get",
    url: "http://193.112.55.79:9090/api/getbrandtitle",
    dataType: "json",
    success: function (res) {
      // console.log(res);
      var htmlStr = template('brandTitleTmp', res);
      $('.hot_content ul').html(htmlStr);
    }
  });


  var pageCount = 1;
  // 前一页
  $('.page .pre').on('click', function(e){
    e.preventDefault();

    console.log(pageCount);
    if(pageCount == 1){
      return;
    }
    
  })
  // 后一页
  $('.page .next').on('click', function(e){
    e.preventDefault();

    console.log(000);
    if(pageCount = pageMax){
      return;
    }
  })

  $('.hot_content ul').on('click','li',function (e) {
    // console.log(e.currentTarget);
    // 获取当前点击对象的id
    var currentLi = e.currentTarget;
    var currentId=currentLi.dataset.id;
    // console.log(currentId);
    if(this.children.length>1){
      $('.brand_content').remove();
      return;
    }
    $.ajax({
      type:'get',
      url: "http://193.112.55.79:9090/api/getbrand?brandtitleid="+currentId,
      dataType:'json',
      success:function (res) {
        // console.log(res);
        var htmlStr = template('brandContentTmp',res)
        $(currentLi).append(htmlStr);
      }
    })
    // console.log(this.children);
  });
})